<template>
  <div id="app">
    <Header :headFlag="headFlag" />
    <main>
      <template v-if="$route.name === 'About'">
        <router-view></router-view>
      </template>
      <template v-else-if="$route.name === 'mesboard'">
        <router-view />
      </template>
      <template v-else>
        <div>
          <div class="container">
            <router-view></router-view>
          </div>
        </div>
        <!-- 底部 -->
        <div v-if="$route.path.includes('detail')" class="footerbar">
          <Footer />
        </div>
      </template>
    </main>
  </div>
</template>
<script>
import Header from "@/components/Header";
import { mapActions } from "vuex";
import Footer from "@/components/Footer";
export default {
  components: {
    Header,
    Footer
  },
  data() {
    return {
      routeList: [],
      cont: 0,
      i: 0,
      headFlag: true,
    };
  },
  watch: {
    $route() {
      if (arguments[0].name !== arguments[1].name) {
        window.scrollTo(0, 0);
      }
    },
  },
  methods: {
    ...mapActions({
      getArticleList: "article/getArticleList",
    }),
    active(ind) {
      this.cont = ind;
    },
    headleScroll() {
      let scroll =
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop;
      if (scroll > this.i) {
        this.i = scroll;
        this.headFlag = false;
      } else {
        this.i = scroll;
        this.headFlag = true;
      }
    },
  },
  mounted() {
    // console.log(this.$route);
    window.addEventListener("scroll", this.headleScroll, true);
  },
  created() {
    this.getArticleList();
  },
};
</script>

<style lang="scss">
header {
  height: 68px;
  width: 100%;
  border-bottom: 1px solid #ccc;
  font-size: 14px !important;
  .logo {
    img {
      width: 120px !important;
      height: 40px !important;
    }
  }
}

main {
  padding-top: 68px;
  z-index: 999;
  background-color: var(--bg-body);
  min-height: calc(100vh - 64px);
}
</style>
